//
//  MYGToolRootVC.swift
//  MYDoctor
//
//  Created by Denny on 2024/4/19.
//

import UIKit

class MYGToolRootVC: MYGBaseController {
    var dataSource = [MYGIndustryExchangesData]()
    lazy var tableView:UITableView = {
        let control = UITableView()
        control.showsVerticalScrollIndicator = false
        control.dataSource = self
        control.rowHeight = 87
        control.delegate = self
        control.separatorStyle = .none
        control.backgroundColor = .clear
        control.register(UINib.init(nibName: "MYGMYGIndustryExchangesCell", bundle: nil), forCellReuseIdentifier: "MYGMYGIndustryExchangesCell")
        return control
    }()
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "效率工具"
        self.view.backgroundColor = UIColor.init(hexString: "#F5F6F8")
        view.addSubview(tableView)
        tableView.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(8)
            make.left.right.bottom.equalToSuperview()
        }
        
        var obj = MYGIndustryExchangesData()
        obj.imageName = "MYG_doctorImage"
        obj.title = "随身影像"
        self.dataSource.append(obj)
        
        var obj1 = MYGIndustryExchangesData()
        obj1.imageName = "MYG_icon_shousu"
        obj1.title = "手术记录"
        self.dataSource.append(obj1)
        
        var obj2 = MYGIndustryExchangesData()
        obj2.imageName = "MYG_icon_tools"
        obj2.title = "医学公式"
        self.dataSource.append(obj2)
        
        var obj3 = MYGIndustryExchangesData()
        obj3.imageName = "MYG_icon_daskCloud"
        obj3.title = "我的云盘"
        self.dataSource.append(obj3)
    
    }
}

extension MYGToolRootVC: UITableViewDataSource,UITableViewDelegate {
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return dataSource.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "MYGMYGIndustryExchangesCell", for: indexPath) as! MYGMYGIndustryExchangesCell
        let model = self.dataSource[indexPath.row]
        cell.titleLB.text = model.title
        cell.icon.image = UIImage(named: model.imageName)
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        if indexPath.row == 0 {
            let vc = MYGSelectUserController()
            self.navigationController?.pushViewController(vc, animated: true)
        }
        if indexPath.row == 1 {
            let vc = MYGSurgicalHistoryViewController()
            self.navigationController?.pushViewController(vc, animated: true)
        }
        
        if indexPath.row == 2 {
            let vc = MYGMedicalToolsHomeController()
            self.navigationController?.pushViewController(vc, animated: true)
        }
        
        if indexPath.row == 3 {
            self.navigationController?.pushViewController(MYCloudDiskViewController(), animated: true)
        }
        
    }
}
